package com.剑指offer.第二章;

public class 乘积小于k的子数组 {

    public static int resolve(int nums[], int k) {
        int left = 0;
        int count = 0;
        int product = 1;
        for (int right = 0; right < nums.length; right++) {
            product *= nums[right];
            while (left <= right && product >= 100) {
                product /= nums[left++];
            }
            count += right >= left ? right - left + 1 : 0;
        }
        return count;
    }

    public static void main(String[] args) {
        System.out.println(resolve(new int[]{10, 5, 2, 6}, 100));
    }

}
